package view.UIPlayer{
	
	import com.greensock.*;
	import com.greensock.easing.*;
	
	import flash.display.Sprite;
	
	import vo.GameModel;
	
	public class CardViewLayer extends Sprite{
		
		private var cardViewList:Array = new Array();
		private var gameModel:GameModel = GameModel.getInstance();
		
		public function CardViewLayer(){
			super();
		}
		
		//显示卡路
		public function displayCard():void{
			clearCardView();
			displayCardMy();
		}
		
		//显示我的卡路
		public function displayCardMy():void{
			gameModel.playMe("assets/sound/sound_2_(flip).mp3");
			
			var timeLine:TimelineLite = new TimelineLite();
			var targetX:int;
			var targetY:int;
			var tmpX:int = -20;
			var tmpY:int = 270;
			
			for(var i:uint=0;i<gameModel.gameCardsVO.myCardList.length; i++){
				var tmpCardView:CardView = new CardView(gameModel.gameCardsVO.myCardList[i]);
				tmpCardView.y = 0;
				tmpCardView.x = stage.width;
				targetX = i * 20 + 150 + tmpX;
				targetY = tmpY;
				addChild(tmpCardView);
				cardViewList.push( tmpCardView );
				TweenLite.to( tmpCardView, 1, {x:targetX, y:targetY, ease:Elastic.easeOut});
			}
		}
		
		//暴力移除卡牌
		public function clearCardView():void{
			trace("CardViewLayer-numChildren:",numChildren);
			while(numChildren > 0){
				this.removeChildAt(0);
			}
		}
	}
}